/*
 * Copyright (C) 2010 Johan Waldeback
 *  
 * This file is part of the OpenFMS project (http://www.openfms-project.org)
 * 
 * OpenFMS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * \class ChannelCtrl
 * \brief Visual control used to display the value of a channel
 *
 * ChannelCtrl is a visual control used to indicate the value of a channel
 * Basically ChannelControll is a progress bar, but without some of the 
 * visually pleasing stuff. ChannelCtrl reacts mush better to 
 * quick changes in the input.
 */

// todo: don't use progress bar, or a better version of it.

#include "ChannelCtrl.h"

const int range_scale = 50;
const int middle_pos = 100; //range_scale*2+1;

ChannelCtrl::ChannelCtrl( wxWindow *parent, wxWindowID id ) : 
	wxGauge( parent, id, middle_pos*2+1, wxDefaultPosition, wxDefaultSize, wxVERTICAL)
{
}
void ChannelCtrl::setValue(float pos)
{
	if( pos >1.f ) pos = 1.f;
	if( pos <-1.f ) pos = -1.f;

	wxGauge::SetValue(static_cast<int>(pos*range_scale)+middle_pos);
}



